package com.yet.rule;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

import com.yet.container.registry.RegistryMeta.Address;
import com.yet.container.registry.RegistryMeta.ServiceMeta;

public interface Rule {

	public Address getLoadBlanceAddress(ServiceMeta serviceMeta, List<Address> adds);

	public static interface Ruleable {
		public void setRule(Rule rule);
	}
	
	/**
	 * 随机
	 */
	static final Rule RANDOM = (serviceMeta,adds)->{
		ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
		return adds.get(threadLocalRandom.nextInt(adds.size()));
	};
	
}
